package com.web.portal.service;

import java.util.EnumMap;
import java.util.List;
import java.util.Map;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import com.web.portal.dao.BaseDao;
import com.web.portal.dao.TutoringCenterSearchType;
import com.web.portal.entity.TutoringCenter;
@Service ("tutoringCenterService")
public class DefaultTutoringCenterService extends DefaultWebPortalService<TutoringCenter> implements TutoringCenterService {
private static final Logger LOG= Logger.getLogger(DefaultTutoringCenterService.class);
	
	@Autowired
	@Qualifier ("tutoringCenterDao")
	public void init(BaseDao dao){
		setBaseDao(dao);
	}
	public List<TutoringCenter> getTutoringCenter(TutoringCenter tutoringCenter) {
		// TODO Auto-generated method stub
		LOG.debug("Getting the Tutoring Center list..................");
		return getList(tutoringCenter);
	}

	public void createOrSave(TutoringCenter tutoringCenter) {
		// TODO Auto-generated method stub
		/*
		 * save tutoring center
		 */
		LOG.debug("Saving the Tutoring Center object................................");
		createOrUpdate(tutoringCenter);
	}

	public TutoringCenter getTutoringCenterById(String id) {
		// TODO Auto-generated method stub
Map<TutoringCenterSearchType, Object> searchCriteria= new EnumMap(TutoringCenterSearchType.class);
searchCriteria.put(TutoringCenterSearchType.ID, id);
List<TutoringCenter> result=searchByCriteria(searchCriteria);
if(!result.isEmpty()&& result.size()==1){
	LOG.debug("Tutoring center object found.................................");
	return result.get(0);
	
}
LOG.debug("Tutoring center object not found in the database.............................");
return null;
	}

	@Override
	@Transactional(readOnly = true, propagation = Propagation.SUPPORTS)
	protected boolean isCreate(TutoringCenter entity) throws RuntimeException {
		// TODO Auto-generated method stub
		return false;
	}

}
